<?php
	$lp_root_path = './';
	$general_root_path = '../';

	define('INSIDE', true);
	include($general_root_path . 'extension.inc');
	include($general_root_path . 'common.'.$phpEx);
	include_once ($lp_root_path ."classes/templates.class.".$phpEx);

	

	if (isset($_POST["register"]))
	{
		$name = make_safe($_POST['name']);
		$password = make_safe($_POST['password']);
		$email = make_safe($_POST['email']);
		$surname=make_safe($_POST['surname']);
		$lang=make_safe($_POST['lang']);
		$profile=make_safe($_POST['profile']);
		$nick=make_safe($_POST['nick']);
		$rol=make_safe($_POST['rol']);
	
		include_once ($lp_root_path ."classes/users.class.".$phpEx);
		$users = array_pop(Users::list_users("`nick`='".$name."'"));
		
		if ($users!=null && is_int($users->get_id()))
			{
			echo 'El jugador ya existe';
	
			}
			else
			{
			
			date_default_timezone_set('Europe/Madrid');
			$fecha  = date("Y-m-d");
			$lastLogin= date("Y-m-d H:i:s");
			Users::createnew_users( null, $name, $surname, md5($password), $lang, $email, "1", "1", "0", $profile, $nick, null, $lastLogin, $lastLogin, $rol );
			}

			header("Location: index.php"); 
	}
	else {
		$template=new Template();
		$template->template_registro();
	
	}
	
?>
